/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 30318
 * Date: 2024-01-17
 * Time: 12:53
 */
import java.util.Scanner;

public class ClientMember {//客户端会员系统
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        TestOfMember testOfMember = new TestOfMember();
        while (true) {
            System.out.println("**************   会员窗口   **************");
            System.out.println("\t\t\t1、注册会员信息");
            System.out.println("\t\t\t2、修改会员信息");
            System.out.println("\t\t\t3、查询会员信息");
            System.out.println("*****************************************");
            System.out.println("请输入对应编号：");
            int n = in.nextInt();
            while (n < 1 || n > 5) {
                System.out.println("输入错误！请重新输入：");
                n = in.nextInt();
            }
            switch (n) {
                case 1://注册会员信息
                    System.out.println("***************   会员注册   **************");
                    testOfMember.addMember();
                    System.out.println("*************   会员注册结束   *************");
                    break;
                case 2://修改会员信息
                    System.out.println("************   会员积分修改   ************");
                    while (true) {
                        System.out.println("请输入您要修改的会员ID：");
                        if (testOfMember.queryMember(in.next())) {
                            String oldstr = testOfMember.toString();
                            System.out.println("请输入您的生日：");
                            String newbirth = in.next();
                            String oldbirth = testOfMember.getMember().getMemberBirth();
                            testOfMember.getMember().setMemberBirth(newbirth);//生日修改
                            String newstr = testOfMember.toString();
                            testOfMember.modify(oldstr, newstr);
                        } else {
                            System.out.println("没要找到该会员！");
                        }
                        System.out.println("是否继续修改？(Y/N)");
                        char c = in.next().charAt(0);
                        if (c == 'n' || c == 'N')
                            break;
                    }
                    System.out.println("***********   会员修改结束   ************");
                    break;
                case 3://查询会员信息
                    System.out.println("*************   会员查询   *************");
                    while (true) {
                        System.out.println("请输入您要查找的会员ID：");
                        if (!testOfMember.queryMember(in.next())) {
                            System.out.println("没要找到该会员！");
                        }
                        System.out.println("是否继续查找？(Y/N)");
                        char c = in.next().charAt(0);
                        if (c == 'n' || c == 'N')
                            break;
                    }
                    System.out.println("************   会员查询结束   ************");
                    break;
                default:
                    System.out.println("您输入编号错误！");
            }
            System.out.println("是否返回上一个界面：Y-是，N-否");
            char ch = in.next().charAt(0);
            if (ch == 'n' || ch == 'N')
                break;
        }
    }
}